package cn.kgc.controller;

import cn.kgc.dto.StudentRequestDTO;
import cn.kgc.dto.StudentResponseDTO;
import cn.kgc.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author mosin
 * date 2022/1/17
 * @version 1.0
 */
@RestController
@RequestMapping("/students")
public class StudentController {
    @Autowired
    private StudentService studentService;

    //查询学生列表
    @GetMapping
    public List<StudentResponseDTO> queryAll(){

        List<StudentResponseDTO>  studentDTOS =  studentService.queryAll();

        return studentDTOS;
    }
    //添加学生

    @PostMapping
    public StudentResponseDTO insert(@RequestBody StudentRequestDTO studentRequestDTO){
        StudentResponseDTO studentResponseDTO =  studentService.insert(studentRequestDTO);
       return studentResponseDTO;
    }


}
